#pragma once

#include "BasicEvent.h"
#include "ProcessInfo.h"

namespace events {

class ThreadEvent :	public BasicEvent
{
public:
	enum ThreadEventType {
		THREAD_EV_CREATE,
		THREAD_EV_FINISH,
		THREAD_EV_EXIT,
		THREAD_EV_TERMINATE
	};

public:
	ThreadEvent(void) : BasicEvent(BasicEvent::EVENT_THREADS), _threadEvType(THREAD_EV_CREATE), _idThread(0) {}

	ThreadEvent(ThreadEventType type, DWORD(id)) : BasicEvent(BasicEvent::EVENT_THREADS), _threadEvType(type), _idThread(id) {}
	ThreadEvent(ThreadEventType type, HANDLE hThread) : BasicEvent(BasicEvent::EVENT_THREADS), _threadEvType(type), _idThread(platform::ProcessInfo::GetThreadIdFromHandle(hThread)) {}

	virtual ~ThreadEvent(void) {}

	// implementing ISerializable
public:
	virtual void saveToStream(std::ostream &os) const;
	virtual void readFromStream(std::istream &is);
	virtual void writeDebugInfo(std::ostream &os) const;


private:
	ThreadEventType _threadEvType;

	DWORD _idThread;
};

}  // end namespace
